Skip to content

Conversation

Akhil-Chaturvedi
Copy link

@Akhil-Chaturvedi Akhil-Chaturvedi commented Oct 3, 2025

Fixes #4016

This addresses the inability to use the saliency module in Android (Java/Kotlin) applications. When generated using build_sdk.py, the native library compiles, but the Java wrapper class (org.opencv.saliency.Saliency) is not generated.

Technical Fix:

The ocv_define_module macro in modules/saliency/CMakeLists.txt was missing the java flag in its WRAP parameter.

Change in modules/saliency/CMakeLists.txt:

OLD
ocv_define_module(saliency opencv_imgproc opencv_features2d WRAP python)

NEW
ocv_define_module(saliency opencv_imgproc opencv_features2d WRAP python java)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Fixes opencv#4016

This addresses the inability to use the `saliency` module in Android (Java/Kotlin) applications.
When generated using `build_sdk.py`, the native library compiles, but the Java wrapper class (`org.opencv.saliency.Saliency`) is not generated.

**Technical Fix:** 
The `ocv_define_module` macro in `modules/saliency/CMakeLists.txt` was missing the `java` flag in its `WRAP` parameter.

**Change in `modules/saliency/CMakeLists.txt`:**

# OLD
ocv_define_module(saliency opencv_imgproc opencv_features2d WRAP python)

# NEW
ocv_define_module(saliency opencv_imgproc opencv_features2d WRAP python java)
@asmorkalov
Copy link
Contributor

@Akhil-Chaturvedi Please handle CI warnings.

@asmorkalov
Copy link
Contributor

  Warning: /home/ubuntu/opencv/modules/core/include/opencv2/core.hpp:3211:26: warning: 'virtual void cv::Algorithm::write(cv::FileStorage&) const' was hidden [-Woverloaded-virtual=]
  Warning: /home/ubuntu/opencv/modules/core/include/opencv2/core.hpp:3224:26: warning: 'virtual void cv::Algorithm::read(const cv::FileNode&)' was hidden [-Woverloaded-virtual=]

saliency: Fix -Woverloaded-virtual in header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to include saliency module in custom OpenCV build (core,imgproc,objdetect)
2 participants